//
//  WCG_O_SingleIndex1TableViewCell.m
//  Project_B
//
//  Created by 黑黑 on 15/11/26.
//  Copyright © 2015年 Atom_Wang. All rights reserved.
//

#import "WCG_O_SingleIndex1TableViewCell.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "UIImage+GIF.h"
@interface WCG_O_SingleIndex1TableViewCell ()

@property (nonatomic, retain) UIImageView *image;
@property (nonatomic, retain) UILabel *titleLable;
@property (nonatomic, retain) UILabel *subtitleLable;

@end
@implementation WCG_O_SingleIndex1TableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSub];
    }
    return self;
}

- (void)createSub
{
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    self.image.contentMode = UIViewContentModeScaleAspectFill;
    self.image.layer.masksToBounds = YES;
    self.image.layer.cornerRadius = 20;
    [self.contentView addSubview:self.image];
    
    self.titleLable = [[UILabel alloc] initWithFrame:CGRectZero];
    self.titleLable.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLable];
    
    self.subtitleLable = [[UILabel alloc] initWithFrame:CGRectZero];
    self.subtitleLable.font = [UIFont systemFontOfSize:11];
    self.subtitleLable.numberOfLines = 2;
    self.subtitleLable.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.subtitleLable];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.contentView).with.offset(10);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(40);
    }];
    [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.image.mas_right).with.offset(10);
        make.top.mas_equalTo(self.image.mas_top).with.offset(0);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(20);
    }];
    [self.subtitleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLable.mas_bottom).with.offset(-5);
        make.left.mas_equalTo(self.image.mas_right).with.offset(10);
        make.height.mas_equalTo(50);
        make.right.mas_equalTo(self.contentView).with.offset(-10);
    }];
}

- (void)setProModel:(GXProviderDataModel *)proModel
{
    if (_proModel != proModel) {
        _proModel = proModel;
    }
    [self.image sd_setImageWithURL:_proModel.avatar placeholderImage:[UIImage sd_animatedGIFNamed:@"loading"]];
    //姓名
    [self.titleLable setText:_proModel.screen_name];
    //简介
    [self.subtitleLable setText:_proModel.provider_description];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
